package com.zkyc.framework.website.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.zkyc.framework.common.pojo.MediaTag;
import com.zkyc.framework.common.pojo.MediaTagGroup;
import com.zkyc.framework.common.vo.ResultVO;
import com.zkyc.framework.website.service.MediaTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author bing.bai
 * @create 2022/6/15
 */
@RestController
@RequestMapping("mediaTag")
public class MediaTagController {

    @Autowired
    private MediaTagService mediaTagService;

    /**
     * 查询
     *
     * @return 查询结果
     */
    @GetMapping("list")
    public ResultVO queryList() {
        return mediaTagService.queryList();
    }

    /**
     * 查询
     *
     * @return 查询结果
     */
    @GetMapping("listByColumnId")
    @HystrixCommand(fallbackMethod = "queryListByColumnIdFallback")
    public ResultVO queryListByColumnId(Integer columnId) {
        return mediaTagService.queryListByColumnId(columnId);
    }
    public ResultVO queryListByColumnIdFallback(Integer columnId) {
        return ResultVO.success("访问超时，请稍后重试");
    }

    /**
     * 新增标签组
     */
    @PostMapping("saveGroup")
    public ResultVO saveGroup(@RequestBody MediaTagGroup mediaTagGroup) {
        return mediaTagService.saveGroup(mediaTagGroup);
    }


    /**
     * 更新标签组
     */
    @PostMapping("updateGroup")
    public ResultVO updateGroup(@RequestBody MediaTagGroup mediaTagGroup) {
        return mediaTagService.updateGroup(mediaTagGroup);
    }

    /**
     * 删除标签组
     *
     */
    @PostMapping("deleteGroup")
    public ResultVO deleteGroup(@RequestBody MediaTagGroup mediaTagGroup) {
        return mediaTagService.deleteGroup(mediaTagGroup);
    }

    /**
     * 新增标签
     */
    @PostMapping("saveTag")
    public ResultVO saveTag(@RequestBody MediaTag mediaTag) {
        return mediaTagService.saveTag(mediaTag);
    }

    /**
     * 修改标签
     */
    @PostMapping("updateTag")
    public ResultVO updateTag(@RequestBody MediaTag mediaTag) {
        return mediaTagService.updateTag(mediaTag);
    }


    /**
     * 删除标签
     */
    @PostMapping("deleteTag")
    public ResultVO deleteTag(@RequestBody MediaTag mediaTag) {
        return mediaTagService.deleteTag(mediaTag);
    }

    @GetMapping("queryContentTag")
    public ResultVO queryContentTag(String columnId) {
        return mediaTagService.queryContentTag(columnId);
    }


}
